<template>
  <div class="app">
    <Header></Header>
    <transition name="el-fade-in-linear" mode="out-in">
      <keep-alive include="Home">
        <router-view :key="$route.fullPath"></router-view>
      </keep-alive>
    </transition>
    <!-- <Footer></Footer> -->
    <FooterV2></FooterV2>
    <!-- <GoTop></GoTop> -->
  </div>
</template>

<script>
import { get, post } from "./api";
import { encrypt, decrypt } from "./crypto/crypto.js";
export default {
  name: "App",
  created() {
    // console.log(window.location.hostname)
    let setUrl = window.location.hostname
    let store = sessionStorage.getItem("store");
    if (store) {
      this.$store.commit("init", JSON.parse(store));
      sessionStorage.removeItem("store");
    }

    window.addEventListener("unload", this.windowUnload);
    this.getToken(setUrl);
  },
  methods: {
    /**页面销毁存储公共状态 */
    windowUnload() {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    },

    //登录获取token
    async getToken(setUrl) {
      let data = {
        username: "admin",
        password: encrypt("123456", "34439a96e68b129093105b67de81c0fc"),
      };
      try {
        const response = await post("/user/login/doLogin", data);
        localStorage.setItem("AUTHORIZATION", response.resData.AUTHORIZATION);
        this.listSiteAll(setUrl);
        // 处理响应数据
      } catch (error) {
        // 处理错误
      }
    },
    //获取站点id
    async listSiteAll() {
      let params = {
        siteDomain: "http://47.99.38.153:9300",
      };
      try {
        const response = await get("/sys/site/listSiteAll", params);
        sessionStorage.setItem("siteId", response.resData[0].siteId);
        this.getList();
        // 处理响应数据
      } catch (error) {
        // 处理错误
      }
    },
  },
};
</script>

<style lang="css" scoped>
.app {
  background: #ffffff;
}
</style>

<style>
.dl {
  display: flex;
  align-items: center;
}

/**颜色变量 */
:root {
  --theme-color: #1891ff;
}

/**element组件样式修改 */
.swiper .el-carousel__button {
  height: 5px !important;
  opacity: 1;
}

.swiper .is-active .el-carousel__button {
  height: 5px !important;
  background-color: var(--theme-color) !important;
}
</style>
